package com.itcast.manager3.D_dao;

import com.itcast.manager3.tomian.TecherTomain;

import java.util.ArrayList;

public class TecherDao {
    private ArrayList<TecherTomain> list = new ArrayList<>();

    public void addTecher(TecherTomain th) {
        list.add(th);
    }

    public ArrayList<TecherTomain> getAllTecher() {
        return list;
    }

    public void deleteTcher(String id) {
        for (int i = 0; i < list.size(); i++) {
            TecherTomain tt = list.get(i);
            if (tt.getId().equals(id)) {
                list.remove(tt);
            }
        }
    }

    public void updateTcher(TecherTomain tt) {
        for (int i = 0; i < list.size(); i++) {
            TecherTomain t1 = list.get(i);
            if (tt.getId().equals(t1.getId())){
                t1.setName(tt.getName());
                t1.setAge(tt.getAge());
                t1.setBirthday(tt.getBirthday());
            }
        }
    }
}
